package csc.fresher.service;

import java.sql.Timestamp;
import java.util.List;

import csc.fresher.entity.SavingTransactionType;
import csc.fresher.entity.Transaction;
import csc.fresher.entity.TransactionState;
import csc.fresher.entity.TransactionType;

public interface SavingTransactionService{
	/**
	 * {@inheritDoc}
	 * Create new transaction for saving account
	 * If transaction type is SAVING or WITHDRAWINTEREST, add new interest rate with status PENDING for this account , account_transaction_state is HOLD 
	 * If transaction type is WITHDRAWALL, account_transaction_state is HOLD 
	 * 
	 * @param funds : amount which user want to saving or withdraw
	 * @param savingAccountNumber
	 * @param beforeTxBalance : amount before creating transaction
	 * @param createdBy
	 * @param savingTransactionType
	 * @param interestRateID
	 * @param fromDate
	 * @param toDate
	 * @return either (1) the transaction identifier for creating successful or (2) < 0 for creating fail
	 */
	public long createTransaction(double funds, long savingAccountNumber, double beforeTxBalance,
			int createdBy,SavingTransactionType savingTransactionType, int interestRateID, Timestamp fromDate, Timestamp toDate);

	/**
	 * {@inheritDoc}
	 * Approve transaction, transaction state will be "DONE" 
	 * If transaction type is SAVING or WITHDRAWINTEREST, new interest rate status is ACCEPTED, account_transaction_state is HOLD 
	 * If transaction type is WITHDRAWALL, account_transaction_state is DONE 
	 * 
	 * @param transactionID
	 * @param accoutNumberID
	 * @param systemUserID
	 * @return 
	 */
	public boolean approveTransactionState(long transactionID, long accoutNumberID, long systemUserID);
	
	/**
	 * {@inheritDoc}
	 * Deny transaction, transaction state will be "DENY" 
	 * If transaction type is SAVING or WITHDRAWINTEREST, new interest rate status is DENY, account_transaction_state is ACTIVE 
	 * If transaction type is WITHDRAWALL, account_transaction_state is ACTIVE 
	 * 
	 * @param transactionID
	 * @param accoutNumberID
	 * @param systemUserID
	 * @return 
	 */
	public boolean denyTransactionState(long transactionID, long accoutNumberID, long systemUserID);

	
	/**
	 * @param accountNumberID
	 * @param begin
	 * @param end
	 * @param startIndex
	 * @param maxReturn
	 * @return
	 */
	public List<Transaction> getListTransactionAccountInAPeriod(
			long accountNumberID, Timestamp begin, Timestamp end,
			int startIndex, int maxReturn);
	
	/**
	 * @param accountNumberID
	 * @param begin
	 * @param end
	 * @return
	 */
	public List<Transaction> getListTransactionAccountInAPeriod(
			long accountNumberID, Timestamp begin, Timestamp end);
	
	/**
	 * @param accountNumber
	 * @return
	 */
	public List<Transaction> getListSavingTransactionByAccountNumber(long accountNumber);

	/**
	 * @param accountNumberID
	 * @param begin
	 * @param end
	 * @param transactionType
	 * @param startIndex
	 * @param maxReturn
	 * @return
	 */
	public List<Transaction> getListTransactionAccountInAPeriodByType(
			long accountNumberID, Timestamp begin, Timestamp end,
			TransactionType transactionType, int startIndex, int maxReturn);

	/**
	 * @param accountNumberID
	 * @param begin
	 * @param end
	 * @param transactionState
	 * @param startIndex
	 * @param maxReturn
	 * @return
	 */
	public List<Transaction> getListTransactionAccountInAPeriodByState(
			long accountNumberID, Timestamp begin, Timestamp end,
			TransactionState transactionState, int startIndex, int maxReturn);

	/**
	 * {@inheritDoc}
	 * 
	 * Get table saving account has interest rate
	 * 
	 * @param accountNumberID
	 * @param startIndex
	 * @param maxReturn
	 * @return
	 */
	public List<Transaction> getListInterestRateOfUser(long accountNumberID,
			int startIndex, int maxReturn);
	
	public List<Transaction> getListTransactionAccountAll();
	public List<Transaction> getListTransactionAccountIsApprove();
	public List<Transaction> getListTransactionAccountIsPending();

	boolean checkActiveCustomerAccountTransactionState(long accountNumber);
}
